package main

import (
	"go-gin-template/config"
	"go-gin-template/middleware"
	"go-gin-template/server"
	"go-gin-template/svc"
	"go-gin-template/util"

	"github.com/spf13/viper"
)

func main() {
	config.LoadSettingFile()

	if env := viper.GetString("Env"); env != "prod" && env != "test" && env != "beta" {
		util.BuildLogger("debug")
	} else {
		util.BuildLogger("error")
	}

	ctx := svc.NewServiceContext()
	r := server.NewRouter(ctx)
	r.Use(middleware.NewRecoverMiddleware().Handle)

	r.Run(viper.GetString("Host") + ":" + viper.GetString("Port"))
}
